<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>

    </style>
</head>
<body>

</body>
<script>
    // 1、 生成四位随机数字验证码
    // 0~9999

    function random(a,b){
        return Math.round(Math.random()*(a-b)+b);
    }
    function Num(){
        return "" + random(0,9) + random(0,9) + random(0,9) + random(0,9);
    }
    console.log(Num());


// 2. 生成四位随机数字字母混合的验证码
// a 97~122，A 65~90,  0~9 48~57
function mix(){
        var str = "";
        for(var i=0;i<200;i++){
            str += random(0,9)
            str += String.fromCharCode(random(97,122))
            str += String.fromCharCode(random(65,90))
        }
        var str2 = "";
        for(var i=0;i<4;i++){
            str2 += str[random(0,str.length-1)]
        }
        return str2;
    }
    console.log(mix())


    // 生成随机的十六进制颜色值
    
    function color(){
        var r = random(0,255).toString(16);
        var g = random(0,255).toString(16);
        var b = random(0,255).toString(16);

        return "#"+r+g+b;
    }
    console.log(color())
    document.body.style.background = color();


    // 随机点名
    var arr = ["张三","李四","王二","赵五","钱六","admin","root"];
    console.log(arr[random(0,arr.length-1)]);



</script>
</html>